﻿package com.tudou.skin.common.button
{
    import com.tudou.skin.common.behavior.*;
    import com.tudou.skin.common.consts.*;
    import com.tudou.skin.common.events.*;
    import flash.display.*;
    import flash.geom.*;

    public class SelectRadioMenu extends Sprite implements ISelecRadio, IAutoClose
    {
        protected var selcetButton:ISelect;
        protected var radioButton:IRadio;
        protected var radioSkin:InteractiveObject;
        protected var selectSkin:InteractiveObject;
        protected var $autoData:Object;
        protected var iButton:IButton;

        public function SelectRadioMenu(param1:ISelect, param2:IRadio, param3:Point, param4:Point)
        {
            $autoData = {};
            selcetButton = param1;
            radioButton = param2;
            iButton = param1 as IButton;
            selectSkin = selcetButton.getSkin();
            radioSkin = radioButton.com.tudou.skin.common.button:IButton::getSkin();
            selectSkin.x = param3.x;
            selectSkin.y = param3.y;
            radioSkin.x = param4.x;
            radioSkin.y = param4.y;
            addChild(selectSkin);
            addChild(radioSkin);
            selcetButton.addEventListener(SelectEvent.CLICK, selectHlr);
            radioButton.addEventListener(RadioEvent.CLICK, radioHlr);
            selected = false;
            return;
        }// end function

        public function getSkin() : InteractiveObject
        {
            return this;
        }// end function

        public function get enable() : Boolean
        {
            return selcetButton.enable;
        }// end function

        public function get activeIndex() : int
        {
            return radioButton.activeIndex;
        }// end function

        public function set enable(param1:Boolean) : void
        {
            selcetButton.enable = param1;
            return;
        }// end function

        public function get autoData() : Object
        {
            return $autoData;
        }// end function

        public function autoClose() : void
        {
            selected = false;
            return;
        }// end function

        public function get selected() : Boolean
        {
            return selcetButton.selected;
        }// end function

        public function set activeIndex(param1:int) : void
        {
            radioButton.activeIndex = param1;
            if (iButton)
            {
                iButton.activeIndex = param1;
            }
            return;
        }// end function

        protected function selectHlr(event:SelectEvent) : void
        {
            dispatchEvent(new SelectEvent(SelectEvent.CLICK, false, true, selected));
            return;
        }// end function

        public function set autoData(param1:Object) : void
        {
            $autoData = param1;
            return;
        }// end function

        public function set activeKey(param1:String) : void
        {
            radioButton.activeKey = param1;
            if (iButton)
            {
                iButton.activeKey = param1;
            }
            return;
        }// end function

        public function getCloseTime() : Number
        {
            return CommonConsts.AUTO_CLOSE_TIME;
        }// end function

        public function get buttonNum() : uint
        {
            return radioButton.buttonNum;
        }// end function

        public function set selected(param1:Boolean) : void
        {
            selcetButton.selected = param1;
            radioSkin.visible = param1;
            if (param1)
            {
                AutoCloseUtil.actBehavior(this);
            }
            else
            {
                AutoCloseUtil.removeBehavior(this);
            }
            return;
        }// end function

        public function get activeKey() : String
        {
            return radioButton.activeKey;
        }// end function

        protected function radioHlr(event:RadioEvent) : void
        {
            dispatchEvent(new RadioEvent(RadioEvent.CLICK, false, true, event.clickIndex, event.clickKey));
            return;
        }// end function

        public function setEnable(param1:int, param2:Boolean) : void
        {
            radioButton.setEnable(param1, param2);
            return;
        }// end function

    }
}
